package com.srwl.mytx.domain;


import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by dahai2070 on 2016/10/6 0006.
 */
public class Topic implements Parcelable {

    private String id;
    private String uId;
    private String managerId;//管理员id
    private String title;
    private Double price;
    private Double auctionPrice;
    private Integer sales;
    private Integer status;

    private Integer commentSize;

    private Integer praiseSize;//点赞

    private String roomId;

    private Double donationBalance;

    private Double donationReceived;

    private Double donationSize;

    private Integer forwardSize;//转发计数

    private Integer taskSize;// 任务数量（最后能结算的任务数量）

    private Integer receiveTaskSize;// 任务已经领取的数量

    private Integer finishTaskSize;//任务已经完成的数量

    private Double deposit;//托管金额，保证金

    private Integer type;
    private Double bidIncrement;//加价幅度
    private Integer refreshCount;//刷新次数
    private User manager;//管理员
    private String content;
    private Date startTime;
    private Date stopTime;
    private String video;
    private String videoCover;
    private List<String> pictures;
    private String address;
    private LatLng location;
    private String hadAddLike;
    private String extra;
    private Date created;
    private Date updated;
    private Coupon coupon;
    private Boolean hadReceive;//标志是否领取了悬赏任务
    private List<MyFile> myFileList;
    private Boolean hadPraise;

    public Boolean getHadPraise() {
        return hadPraise==null?false:hadPraise;
    }

    public void setHadPraise(Boolean hadPraise) {
        this.hadPraise = hadPraise;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public String getManagerId() {
        return managerId;
    }

    public void setManagerId(String managerId) {
        this.managerId = managerId;
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getCommentSize() {
        return commentSize;
    }

    public void setCommentSize(Integer commentSize) {
        this.commentSize = commentSize;
    }

    public Integer getPraiseSize() {
        return praiseSize;
    }

    public void setPraiseSize(Integer praiseSize) {
        this.praiseSize = praiseSize;
    }

    public String getRoomId() {
        return roomId;
    }

    public void setRoomId(String roomId) {
        this.roomId = roomId;
    }

    public LatLng getLocation() {
        return location;
    }

    public void setLocation(LatLng location) {
        this.location = location;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }


    public Integer getRefreshCount() {
        return refreshCount;
    }

    public void setRefreshCount(Integer refreshCount) {
        this.refreshCount = refreshCount;
    }

    public Double getBidIncrement() {
        return bidIncrement;
    }

    public void setBidIncrement(Double bidIncrement) {
        this.bidIncrement = bidIncrement;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getVideo() {
        return video;
    }

    public void setVideo(String video) {
        this.video = video;
    }

    public String getVideoCover() {
        return videoCover;
    }

    public void setVideoCover(String videoCover) {
        this.videoCover = videoCover;
    }

    public List<String> getPictures() {
        if (pictures == null) {
            pictures = new ArrayList<>();
        }
        return pictures;
    }

    public void setPictures(List<String> pictures) {
        this.pictures = pictures;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getStopTime() {
        return stopTime;
    }

    public void setStopTime(Date stopTime) {
        this.stopTime = stopTime;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getAuctionPrice() {
        return auctionPrice;
    }

    public void setAuctionPrice(Double auctionPrice) {
        this.auctionPrice = auctionPrice;
    }

    public User getManager() {
        return manager;
    }

    public void setManager(User manager) {
        this.manager = manager;
    }

    public Integer getSales() {
        return sales;
    }

    public void setSales(int sales) {
        this.sales = sales;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Double getDonationBalance() {
        return donationBalance;
    }

    public void setDonationBalance(Double donationBalance) {
        this.donationBalance = donationBalance;
    }

    public Double getDonationReceived() {
        return donationReceived;
    }

    public void setDonationReceived(Double donationReceived) {
        this.donationReceived = donationReceived;
    }

    public Double getDonationSize() {
        return donationSize;
    }

    public void setDonationSize(Double donationSize) {
        this.donationSize = donationSize;
    }

    public Integer getForwardSize() {
        return forwardSize;
    }

    public void setForwardSize(Integer forwardSize) {
        this.forwardSize = forwardSize;
    }


    public Integer getTaskSize() {
        return taskSize;
    }

    public void setTaskSize(Integer taskSize) {
        this.taskSize = taskSize;
    }

    public Integer getReceiveTaskSize() {
        return receiveTaskSize;
    }

    public void setReceiveTaskSize(Integer receiveTaskSize) {
        this.receiveTaskSize = receiveTaskSize;
    }

    public Integer getFinishTaskSize() {
        return finishTaskSize;
    }

    public void setFinishTaskSize(Integer finishTaskSize) {
        this.finishTaskSize = finishTaskSize;
    }

    public Double getDeposit() {
        return deposit;
    }

    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getHadAddLike() {
        return hadAddLike;
    }

    public void setHadAddLike(String hadAddLike) {
        this.hadAddLike = hadAddLike;
    }

    public List<MyFile> getMyFileList() {
        return myFileList;
    }

    public void setMyFileList(List<MyFile> myFileList) {
        this.myFileList = myFileList;
    }

    public Coupon getCoupon() {
        return coupon;
    }

    public void setCoupon(Coupon coupon) {
        this.coupon = coupon;
    }


    public boolean isHadReceive() {
        return hadReceive == null ? false : hadReceive;
    }

    public void setHadReceive(Boolean hadReceive) {
        this.hadReceive = hadReceive;
    }

    public Topic() {
    }

    @Override
    public String toString() {
        return "Topic{" +
                "id='" + id + '\'' +
                ", uId='" + uId + '\'' +
                ", managerId='" + managerId + '\'' +
                ", title='" + title + '\'' +
                ", price=" + price +
                ", auctionPrice=" + auctionPrice +
                ", sales=" + sales +
                ", status=" + status +
                ", commentSize=" + commentSize +
                ", praiseSize=" + praiseSize +
                ", roomId='" + roomId + '\'' +
                ", donationBalance=" + donationBalance +
                ", donationReceived=" + donationReceived +
                ", donationSize=" + donationSize +
                ", forwardSize=" + forwardSize +
                ", taskSize=" + taskSize +
                ", receiveTaskSize=" + receiveTaskSize +
                ", finishTaskSize=" + finishTaskSize +
                ", deposit=" + deposit +
                ", type=" + type +
                ", bidIncrement=" + bidIncrement +
                ", refreshCount=" + refreshCount +
                ", manager=" + manager +
                ", content='" + content + '\'' +
                ", startTime=" + startTime +
                ", stopTime=" + stopTime +
                ", video='" + video + '\'' +
                ", pictures=" + pictures +
                ", address='" + address + '\'' +
                ", location=" + location +
                ", hadAddLike='" + hadAddLike + '\'' +
                ", extra='" + extra + '\'' +
                ", created=" + created +
                ", updated=" + updated +
                ", coupon=" + coupon +
                ", hadReceive=" + hadReceive +
                ", myFileList=" + myFileList +
                ", hadPraise=" + hadPraise +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.uId);
        dest.writeString(this.managerId);
        dest.writeString(this.title);
        dest.writeValue(this.price);
        dest.writeValue(this.auctionPrice);
        dest.writeValue(this.sales);
        dest.writeValue(this.status);
        dest.writeValue(this.commentSize);
        dest.writeValue(this.praiseSize);
        dest.writeString(this.roomId);
        dest.writeValue(this.donationBalance);
        dest.writeValue(this.donationReceived);
        dest.writeValue(this.donationSize);
        dest.writeValue(this.forwardSize);
        dest.writeValue(this.taskSize);
        dest.writeValue(this.receiveTaskSize);
        dest.writeValue(this.finishTaskSize);
        dest.writeValue(this.deposit);
        dest.writeValue(this.type);
        dest.writeValue(this.bidIncrement);
        dest.writeValue(this.refreshCount);
        dest.writeParcelable(this.manager, flags);
        dest.writeString(this.content);
        dest.writeLong(this.startTime != null ? this.startTime.getTime() : -1);
        dest.writeLong(this.stopTime != null ? this.stopTime.getTime() : -1);
        dest.writeString(this.video);
        dest.writeString(this.videoCover);
        dest.writeStringList(this.pictures);
        dest.writeString(this.address);
        dest.writeParcelable(this.location, flags);
        dest.writeString(this.hadAddLike);
        dest.writeString(this.extra);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeParcelable(this.coupon, flags);
        dest.writeValue(this.hadReceive);
        dest.writeTypedList(this.myFileList);
        dest.writeValue(this.hadPraise);
    }

    protected Topic(Parcel in) {
        this.id = in.readString();
        this.uId = in.readString();
        this.managerId = in.readString();
        this.title = in.readString();
        this.price = (Double) in.readValue(Double.class.getClassLoader());
        this.auctionPrice = (Double) in.readValue(Double.class.getClassLoader());
        this.sales = (Integer) in.readValue(Integer.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.commentSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.praiseSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.roomId = in.readString();
        this.donationBalance = (Double) in.readValue(Double.class.getClassLoader());
        this.donationReceived = (Double) in.readValue(Double.class.getClassLoader());
        this.donationSize = (Double) in.readValue(Double.class.getClassLoader());
        this.forwardSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.taskSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.receiveTaskSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.finishTaskSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.deposit = (Double) in.readValue(Double.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.bidIncrement = (Double) in.readValue(Double.class.getClassLoader());
        this.refreshCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.manager = in.readParcelable(User.class.getClassLoader());
        this.content = in.readString();
        long tmpStartTime = in.readLong();
        this.startTime = tmpStartTime == -1 ? null : new Date(tmpStartTime);
        long tmpStopTime = in.readLong();
        this.stopTime = tmpStopTime == -1 ? null : new Date(tmpStopTime);
        this.video = in.readString();
        this.videoCover = in.readString();
        this.pictures = in.createStringArrayList();
        this.address = in.readString();
        this.location = in.readParcelable(LatLng.class.getClassLoader());
        this.hadAddLike = in.readString();
        this.extra = in.readString();
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        this.coupon = in.readParcelable(Coupon.class.getClassLoader());
        this.hadReceive = (Boolean) in.readValue(Boolean.class.getClassLoader());
        this.myFileList = in.createTypedArrayList(MyFile.CREATOR);
        this.hadPraise = (Boolean) in.readValue(Boolean.class.getClassLoader());
    }

    public static final Creator<Topic> CREATOR = new Creator<Topic>() {
        @Override
        public Topic createFromParcel(Parcel source) {
            return new Topic(source);
        }

        @Override
        public Topic[] newArray(int size) {
            return new Topic[size];
        }
    };
}
